import QtQuick
import QtQuick.Controls
import qml_menu_style
import "." as Components

MenuBar {
    id: mainMenuBar

    height: 30  // 设置固定高度
    spacing: 6  // 菜单项之间的间距

    // 菜单栏边框样式
    background: Rectangle {
        color: MenuTheme.colors.menuBarBackground
        border.color: MenuTheme.colors.borderColor
        border.width: 1
    }

    // 菜单栏中每一项的背景边框与文字样式
    delegate: MenuBarItem {
        id: menuBarItem
        height: parent.height
        padding: 0
        contentItem: Text {
            text: menuBarItem.text
            font.pixelSize: MenuTheme.fontSize
            color: menuBarItem.highlighted ? MenuTheme.colors.highlightedText : MenuTheme.colors.textColor
            horizontalAlignment: Text.AlignLeft
            verticalAlignment: Text.AlignVCenter
            leftPadding: 8
            rightPadding: 8
        }

        background: Rectangle {
            color: menuBarItem.highlighted ? MenuTheme.colors.highlightColor : "transparent"
        }
    }


    Components.BaseMenu {
        title: "文件"

        Components.BaseMenuItem {
            text: "新建"
            onTriggered: console.log("新建文件")
        }

        Components.BaseMenuItem {
            text: "打开"
        }

        Components.BaseMenu {
            title: "最近打开"

            Components.BaseMenuItem {
                text: "文档1.qml"
            }

            Components.BaseMenuItem {
                text: "项目2.pro"
                enabled: false
            }
        }
    }

    Components.BaseMenu {
        title: "编辑"

        Components.BaseMenuItem {
            text: "撤销"
            onTriggered: console.log("撤销")
        }

        Components.BaseMenuItem {
            text: "复制"
        }

        Components.BaseMenuItem {
            text: "粘贴"
        }

        Components.BaseMenuItem {
            text: "剪切"
        }
    }
} 
